<?php
/*
 discuz
 显示论坛表,结构

 by lost63.com 2010.8.17
 */
$dbhost='localhost'; //服务器
$dbuser='root'; //用户名
$dbpw='myoa888'; //密码
$dbname='pipiqiu'; //数据库名
$tablepre='pre_'; //表前缀
header("Content-type:text/html; char=gb2312");
mysql_connect($dbhost,$dbuser,$dbpw) or die('数据库连接失败');
mysql_query("set names gb2312");
mysql_select_db($dbname) or die('找不到数据库');
echo '<style>*{font-size:12px;}.fenlei{width:250px;float:left;display:inline;}.pic{height:60px;float:left;display:inline;}</style>';

$tb_names=mysql_list_tables($dbname);

$tables=array(); //表名数组

/* 数据库所有表 */
while($row=mysql_fetch_row($tb_names)){
    $tables[]=$row[0];
}
echo $dbname.'该数据库含有<font color=red>'.count($tables).'</font>个表,显示如下:<br>';
echo '<div class="fenlei"></div>';
foreach($tables as $v){
    echo '<div class="fenlei">'.$v.'</div>';
}
echo '</table>';

/* 结构显示 */
echo '<p>======================= 结构显示 ======================= </p>';
for($i=0;$i<count($tables);$i++){
    $query=mysql_query("select * from `".$tables[$i]."`");

    while($row=mysql_fetch_field($query)){
        $fd.=str_pad(" ",2).$row->name." ".$row->type."(".$row->max_length."),";
    }
    $fd=substr($fd,0,-1)."n";
    $fd=str_replace(",",",n",$fd);

    echo '<table width="100" border="0" cellpadding="8" cellspacing="1" bgcolor="#CCCCCC" style="float:left;display:inline;margin-left:4px;margin-top:4px;">
 <tr>
 <td align="center" bgcolor="#FFFFFF"><strong>'.$tables[$i].'</strong></td>
 </tr>
 <tr>
 <td bgcolor="#FFFFFF">'.$fd.'</td>
 </tr>
 </table>';
    unset($fd);
}

echo '<p style="clear:both;">======================= 显示完毕 ======================= </p>';